<?php
/**
 * 验证的跳转页面
 */
apf_require_controller("Abstract");

class Flow_VerifySecurityController extends AbstractController {

    public function handle_request() {
        //已设置了密码，不需要再次设置
        if(isset($_SESSION['user_security_enable']) && $_SESSION['user_security_enable'] == '1'){
            APF::get_instance()->get_response()->redirect(Portal_Urls::base_url());
        }
        //用户并未有密码，不需要输入密码
        if(!$this->_check_user_enable()) {
            APF::get_instance()->get_response()->redirect(Portal_Urls::base_url());
        }
        $params = $this->request->get_parameters();
        $params['url'] = base64_decode($params['url']);
        $this->request->set_attribute('jump_last_url', $params['url']);
        return 'Flow_VerifySecurity';
    }

    private function _check_user_enable() {
        apf_require_class("Bll_Flow_UserSecurityKey");
        $bll_key = new Bll_Flow_UserSecurityKey();
        $data = APF::get_instance()->get_request()->get_attributes();
        if(empty($data['userinfo']['user_id'])) {
            return false;
        }
        $rs = $bll_key->get_user_miwen($data['userinfo']['user_id']);
        return $rs ? true:false;
    }

}